import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { PlayerOpRegister } from "../../common/menu/PlayerOpRegister";
import { PlayerOpMenuConst } from "../../common/menu/PlayerOpMenuConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Cache } from "../../../cache/Cache";
import { MsgManager } from "../../../manager/MsgManager";
//class ChatPublicCrossCellRenderer
    
    export  class ChatPublicCrossCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.initStyles();
            this.initView();
            this.addEventListener(flash.events.MouseEvent.DOUBLE_CLICK, this.dblClickHandler);
            return;
        }

        /* internal  */initView(): void
        {
            this._tx = ObjCreate.createTextField("", 0, 0, 148, 22, this);
            this._tx.autoSize = flash.text.TextFormatAlign.LEFT;
            return;
        }

        /* internal  */initStyles(): void
        {
            this.setStyle("downSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("overSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedOverSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedUpSkin", GlobalClass.getBitmap("Friend_over"));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            this._info = arg1 as SPublicMiniPlayer;
            if (this._info) 
            {
                this._playerMiniInfo = null;
                this._playerMiniInfo = new PlayerMiniInfo(this._info);
                if (EntityUtil.isSameServerByRole(this._info.entityId)) 
                {
                    loc1 = HTMLUtil.addColor(Language.getString(70801), "#FF00FF");
                    PlayerOpRegister.Register(this, this._playerMiniInfo, PlayerOpMenuConst.ChatOpMenu);
                }
                else 
                {
                    loc1 = HTMLUtil.addColor("[" + EntityUtil.getProxyName(this._info.entityId) + "]", "#FF8040");
                    PlayerOpRegister.Register(this, this._playerMiniInfo, PlayerOpMenuConst.PublicCrossChatOpMenu);
                }
                this._tx.htmlText = loc1 + " " + HTMLUtil.addColor(this._info.name, GlobalStyle.color1);
            }
            else 
            {
                this._tx.text = "";
                PlayerOpRegister.UnRegister(this);
            }
            return;
        }

        /* internal  */dblClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._playerMiniInfo = null;
            this._playerMiniInfo = new PlayerMiniInfo(this._info);
            if (EntityUtil.toString(this._info.entityId) == EntityUtil.toString(Cache.instance.role.entityInfo.entityId)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(70802));
                return;
            }
            if (this._info && this._info.online == 1) 
            {
                this._playerMiniInfo = null;
                this._playerMiniInfo = new PlayerMiniInfo(this._info);
                PlayerOpMenuConst.Opearte(PlayerOpMenuConst.ChatPirvate, this._playerMiniInfo);
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(40353));
            }
            PlayerOpRegister.HideOpList();
            return;
        }

        /* internal */ /* var */_tx: Object /* flash.text.TextField */;

        /* internal */ /* var */_info: SPublicMiniPlayer;

        /* internal */ /* var */_playerMiniInfo: PlayerMiniInfo;
    }
